/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import java.sql.*;

/**
 *
 * @author Jason Sorbello
 */
public class MySQLTicketDAO implements TicketDAO {

    private ResultSet rs;
    private Statement stmt;

    public void editTax(int ticketId, int taxValue) {
        Connection con = MySQLDAOFactory.createConnection();
        try {
            stmt = con.createStatement();
            rs = stmt.executeQuery("UPDATE `TICKET` SET TAX = '" + taxValue + "' WHERE TICKET_ID = " + ticketId + ";");

        } catch (Exception e) {
            System.out.println("Error message " + e.getMessage());
        }

    }

    public void buyTicket(int ticketId) {
        Connection con = MySQLDAOFactory.createConnection();
        try {
            stmt = con.createStatement();
            rs = stmt.executeQuery("UPDATE `FLIGHT_LEG` SET SEATS_AVAILABLE = SEATS_AVAILABLE-=1 WHERE FLIGHT_ID = (SELECT FLIGHT_ID FROM TICKET WHERE TICKET_ID = " + ticketId + ");");

        } catch (Exception e) {
            System.out.println("Error message " + e.getMessage());
        }
    }
}
